/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mysweethome.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author BKC
 */
@Entity
@Table(name = "Follow", catalog = "MySweetHomeDB", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Follow.findAll", query = "SELECT f FROM Follow f"),
    @NamedQuery(name = "Follow.findByFollowedDate", query = "SELECT f FROM Follow f WHERE f.followedDate = :followedDate"),
    @NamedQuery(name = "Follow.findByPropertyInfoID", query = "SELECT f FROM Follow f WHERE f.followPK.propertyInfoID = :propertyInfoID"),
    @NamedQuery(name = "Follow.findByCustomerID", query = "SELECT f FROM Follow f WHERE f.followPK.customerID = :customerID")})
public class Follow implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected FollowPK followPK;
    @Basic(optional = false)
    @Column(name = "FollowedDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date followedDate;
    @JoinColumn(name = "PropertyInfoID", referencedColumnName = "PropertyInfoID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private GeneralInfo generalInfo;
    @JoinColumn(name = "CustomerID", referencedColumnName = "CustomerID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Customer customer;

    public Follow() {
    }

    public Follow(FollowPK followPK) {
        this.followPK = followPK;
    }

    public Follow(FollowPK followPK, Date followedDate) {
        this.followPK = followPK;
        this.followedDate = followedDate;
    }

    public Follow(int propertyInfoID, int customerID) {
        this.followPK = new FollowPK(propertyInfoID, customerID);
    }

    public FollowPK getFollowPK() {
        return followPK;
    }

    public void setFollowPK(FollowPK followPK) {
        this.followPK = followPK;
    }

    public Date getFollowedDate() {
        return followedDate;
    }

    public void setFollowedDate(Date followedDate) {
        this.followedDate = followedDate;
    }

    public GeneralInfo getGeneralInfo() {
        return generalInfo;
    }

    public void setGeneralInfo(GeneralInfo generalInfo) {
        this.generalInfo = generalInfo;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (followPK != null ? followPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Follow)) {
            return false;
        }
        Follow other = (Follow) object;
        if ((this.followPK == null && other.followPK != null) || (this.followPK != null && !this.followPK.equals(other.followPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mysweethome.entities.Follow[followPK=" + followPK + "]";
    }

}
